#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time    : 2021/5/21 13:34
# @File    : use_transformer.py
# @Author  : lxy
from pyspark.ml.feature import VectorAssembler
from pyspark.sql import SparkSession
spark = SparkSession.builder.appName("UserDataFrame").getOrCreate()
spark.sparkContext.setLogLevel("WARN")
df = spark.read.csv("/master/train.csv",encoding="utf8",header=False,inferSchema=True,sep=",")
print("----------转换前-----------")
df.show()
df.printSchema()
vec_ass = VectorAssembler(inputCols=['_c0'],outputCol="feature")
feature_df = vec_ass.transform(df)
print("----------转换后-----------")
feature_df.show()
feature_df.printSchema()
spark.stop()